<?php
/* @var $this SiteController */
/* @var $model LoginForm */
/* @var $form TbActiveForm */

$this->pageTitle = '登录';
if ($model->hasErrors()) {
	$js =<<<EOT
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
function s(id,pos){g(id).left=pos+'px';}
function g(id){return document.getElementById(id).style;}
function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}}
addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);});
EOT;
Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$this->id, $js, CClientScript::POS_HEAD);
}
?>
<div class="sign sign-login">
	<h1>登录</h1>

	<?php $this->widget('bootstrap.widgets.TbAlert'); ?>

	<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
		'id' => 'login-form',
		'enableClientValidation' => true,
		'clientOptions' => array(
			'validateOnSubmit' => true,
		),
	)); ?>

	<?php echo $form->textFieldRow($model, 'username', array('class' => 'input-block-level')); ?>

	<?php echo $form->passwordFieldRow($model, 'password', array('class' => 'input-block-level')); ?>

	<?php if (CCaptcha::checkRequirements()): ?>
		<?php echo $form->captchaRow($model, 'verifyCode', array('class' => 'span2')); ?>
	<?php endif; ?>

	<?php echo $form->checkBoxRow($model, 'rememberMe'); ?>

	<div class="text-right">
	<?php $this->widget('bootstrap.widgets.TbButton', array(
		'buttonType' => 'submit',
		'type' => 'primary',
		'label' => '登录',
	)); ?>
	</div>

	<?php $this->endWidget(); ?>

	<?php if (Yii::app()->hasComponent('mail') && Yii::app()->option->get('enableBackendForgetPassword')): ?>
		<p class="sign-nav"><?php echo CHtml::link('忘记密码了？', array('lostPassword')) ?></p>
	<?php endif; ?>
	<script type="text/javascript">
		function wp_attempt_focus(){
			setTimeout( function(){ try{
				d = document.getElementById('LoginForm_username');
				d.focus();
				d.select();
			} catch(e){}
			}, 200);
		}

		wp_attempt_focus();
		if(typeof wpOnload=='function')wpOnload();
	</script>
</div>
